//装备法宝神器 {"序列":1,"目标":1,"类型":"法宝"}
// @ts-ignore
export async function execute(client_id,message_json) {
    let characters = G.Characters.get_current_login_characters(client_id);
    let type = message_json["类型"];
    let index = message_json["序列"] - 1;
    let target_index = message_json["目标"] - 1;
    let src = undefined;
    if (type === "法宝") {
        if (characters["法宝"][index] === undefined || characters["法宝"][index] === null) {
            ClientUtils.send_basic_prompt(client_id, "法宝不存在");
            return;
        }
        src = characters["法宝"][index];
    }
    if (type === "神器") {
        src = characters["神器"];
    }
    let target = characters["法宝佩戴"][target_index];
    if (target === undefined || target === null) {
        //目标位置没有装备
        characters["法宝佩戴"][target_index] = src;
        if (type === "法宝") {
            characters["法宝"][index] = null;
        }
        if (type === "神器") {
            characters["神器"]["佩戴"] = true;
            characters["神器"]["位置"] = index;
        }
    } else {
        //目标位置已装备
        if (target["物品类型"] === "法宝") {
            let tmp_target = Object.assign({}, target);
            characters["法宝佩戴"][target_index] = src;
            characters["法宝"][index] = tmp_target;
        }
        if (target["物品类型"] === "神器") {
            characters["法宝"][index] = src;
            characters["神器"]["佩戴"] = true;
            characters["神器"]["位置"] = index;
        }
    }
    G.Characters.refrush_fabao_data(characters);
}
